package com.mlz.mlzmall.ui.dialog;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.mlz.mlzmall.R;
import com.mlz.mlzmall.ui.activity.act.main.MainActivity;

/**
 * describe :
 * Created by Pm on 2016/5/27.
 * PackageName com.mlz.mlzmall.ui.dialog.
 * ProjectName mlzmall_android.
 */

public class AddCartPopupWindow {
    public static View pw;
    public static PopupWindow pWindow;
    public static TextView tv_addToCart;
    public static TextView tv_addGoToCart;
    public static void AddCartPopup(final Activity context) {
        //  退出对话框
        pw = LayoutInflater.from(context).inflate(R.layout.dialog_addtocart, null);
        tv_addToCart=(TextView)pw.findViewById(R.id.continue_shopping);
        tv_addGoToCart=(TextView)pw.findViewById(R.id.goto_cart);
        tv_addToCart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                pWindow.dismiss();
            }
        });
        tv_addGoToCart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent1 = new Intent(context,MainActivity.class);
//                intent1.putExtra("ShoppingCartFragment","ShoppingCartFragment");
//                context.finish();
//                Intent intent = new Intent();
//                intent.setAction();
                pWindow.dismiss();
                context.sendBroadcast(new Intent("ShoppingCartFragment"));
                context.startActivity(intent1);
//                context.finish();
            }
        });
        pWindow = new PopupWindow(pw, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);//弹框显示大小
        pWindow.setFocusable(true);
        pWindow.setOutsideTouchable(true);

        pWindow.setBackgroundDrawable(new ColorDrawable(0x55000000));//设置背景为透明
  //      pWindow.setAnimationStyle(R.style.AnimationBottom);
        pWindow.showAtLocation(pw, Gravity.CENTER, 0, 0);
    }

}
